<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
  <!ENTITY copy "&#169;">
  <!ENTITY nbsp "&#160;">
  <!ENTITY laquo "&#171;">
  <!ENTITY raquo "&#187;">
]>
<xsl:stylesheet xmlns="http://www.w3.org/1999/xhtml"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
                version="1.0">

  <xsl:include href="layout.xsl"/>

  <xsl:template match="/">
    <xsl:apply-templates />
  </xsl:template>

  <xsl:template match="List">
    <script type="text/javascript" src="js/listing.js"></script>
    <script type="text/javascript" src="js/struct.js"></script>
    <form id="list_form" name="list_form" action="" method="post">
      <input type="hidden" id="controller" value="{$Controller}"/>
      <input type="hidden" id="table_name" value="{$Main/List/head/@table_name}"/>
      <table width="100%" border="0" cellpadding="0" cellspacing="0" class="widefat">
        <thead>
          <tr class="header" bgColor="#EFEFEF">
            <td width="60%">
              Структура сайта
            </td>

            <td width="20%">
              Тип Меню
            </td>

            <xsl:for-each select="$Main/List/func/row">
              <td align="center">
                <xsl:value-of select="title"/>
              </td>
            </xsl:for-each>
            <!--  <xsl:if test="func">
            <td width="13%" colSpan="{func/@count}" style="TEXT-ALIGN: center">
              <div align="center">Действие</div>
            </td>
          </xsl:if>
          -->
          </tr>
        </thead>
        <tbody>
          <xsl:variable name="var_l" select="$Main/List/data/data/row[id=$Main/@id_cat_view]/l" />
          <xsl:variable name="var_r" select="$Main/List/data/data/row[id=$Main/@id_cat_view]/r" />

          <xsl:for-each select="data/data/row[l &gt;= $var_l and r &lt;= $var_r]">
            <xsl:variable name="id" select="id" />
            <xsl:variable name="is_active" select="is_active" />
            <xsl:variable name="is_show" select="is_show" />

            <tr class="datalist tree-closed" id="row{id}" l="{l}" r="{r}" parent="{parent_id}">
              <xsl:if test="id != 62 and id != 87 and id != 1">
                <xsl:attribute name="style">display:none;</xsl:attribute>
              </xsl:if>
              <td class="cur">
                <!--<a href="javascript:;" onclick="treeToggle({id})">+</a>-->
                <xsl:choose>
                  <xsl:when test="r - l > 1">
                    <ins class="tree-icon" onclick="treeToggle({id})">&nbsp;</ins>
                  </xsl:when>
                  <xsl:otherwise>
                    <img src="{$Images}/spacer.gif" width="18" height="1" align="left"/>
                  </xsl:otherwise>
                </xsl:choose>

                <img src="{$Images}/spacer.gif" width="{16*level}" height="1" align="left"/>
                <xsl:choose>
                  <xsl:when test="id_type = 2">
                    <img src="{$Images}/icons/page_white.png" />
                  </xsl:when>
                  <xsl:when test="id_type = 3">
                    <img src="{$Images}/icons/page_white_stack.png" />
                  </xsl:when>
                  <xsl:when test="id_type = 8">
                    <img src="{$Images}/icons/pictures.png" />
                  </xsl:when>
                  <xsl:when test="id_type = 9">
                    <img src="{$Images}/icons/lock.png" />
                  </xsl:when>
                  <xsl:when test="id_type = 10 or id_type = 13 or id_type = 11">
                    <img src="{$Images}/icons/group.png" />
                  </xsl:when>
                  <xsl:otherwise>
                    <img src="{$Images}/icons/folder.png" />
                  </xsl:otherwise>
                </xsl:choose>
                &nbsp;
                <a href="/{$Controller}/{$id}">
                  <xsl:value-of select="menu_name_ru"/>
                </a>
              </td>

              <td>
                <xsl:value-of select="menu"/>
              </td>

              <!-- Function List -->
              <xsl:for-each select="node()[@type = 'func']">
                <td align="center">
                  <xsl:choose>
                    <!-- Checkbox -->
                    <xsl:when test="./type = 'checkbox'">
                      <a href="javascript:;" onclick="return list_func_checkbox({$id}, '{./field}');">
                        <xsl:if test="./ajax">
                          <xsl:attribute name="onclick">
                            <xsl:value-of select="./ajax"/>(<xsl:value-of select="$id"/>, '<xsl:value-of select="./field"/>')
                          </xsl:attribute>
                        </xsl:if>
                        <input type="hidden" value="{./value}" rel="{./field}{$id}"/>
                        <div class="loader{./field}{$id}" style="display:none;">
                          <img src="{$Images}/loader.gif" alt="Выполняется..." title="Выполняется..."/>
                        </div>
                        <div class="func{./field}{$id}">
                          <xsl:choose>
                            <xsl:when test="./value = 1">
                              <div class="on" rel="{./field}{$id}" value="0">
                                <img src="{$Images}/{./img/on}" alt="{./title}" title="{./title}"/>
                              </div>
                              <div style="display:none;" class="off" rel="{./field}{$id}" value="1">
                                <img src="{$Images}/{./img/off}" alt="{./title}" title="{./title}" />
                              </div>
                            </xsl:when>
                            <xsl:otherwise>
                              <div style="display:none;" class="on" rel="{./field}{$id}" value="0">
                                <img src="{$Images}/{./img/on}" alt="{./title}" title="{./title}"/>
                              </div>
                              <div class="off" rel="{./field}{$id}" value="1">
                                <img src="{$Images}/{./img/off}" alt="{./title}" title="{./title}" />
                              </div>
                            </xsl:otherwise>
                          </xsl:choose>
                        </div>
                      </a>
                    </xsl:when>

                    <!-- ORDER -->
                    <xsl:when test="./type = 'order'">
                      <a style="float:left;" href="/{$Controller}/order/id/{$id}/d/1">
                        <img src="{$Images}/{./img/up}" alt="Поднять" title="Поднять"/>
                      </a>
                      <a style="float:left;" href="/{$Controller}/order/id/{$id}/d/2">
                        <img src="{$Images}/{./img/down}" alt="Опустить" title="Опустить" />
                      </a>
                      <input type="text" name="norder" value="{./value}" rel="{$id}" size="4" old="{./value}" cat="{$Form/id_cat/row[@active=1]/id}" style="text-align: center;"/>
                    </xsl:when>

                    <xsl:when test="./type = 'button'">
                      <a href="/{$Controller}/{./name}/id/{$id}">
                        <xsl:if test="./ajax">
                          <xsl:attribute name="onclick">
                            <xsl:value-of select="./ajax"/>(<xsl:value-of select="$id"/>)
                          </xsl:attribute>
                          <xsl:attribute name="href">javascript:;</xsl:attribute>
                        </xsl:if>
                        <img src="{$Images}/{./img}" alt="{./title}" title="{./title}" />
                      </a>
                    </xsl:when>
                  </xsl:choose>
                </td>
              </xsl:for-each>

              <!--
            <xsl:for-each select="/page/content/Main/List/func/row">
              <td>
                <div align="center">
                  <A href="{$Root}/{/page/settings/controller}/{action}/id/{$id}">
                    <xsl:choose>
                      <xsl:when test="action = 'remove'">
                        <img src="{$Images}/folder_delete.png" onclick="return confirm('Удалить?');"  alt="Удалить" title="Удалить"/>
                      </xsl:when>
                      <xsl:when test="action = 'add'">
                        <img src="{$Images}/add.png" alt="Добавить" title="Добавить"/>
                      </xsl:when>
                      <xsl:when test="action = 'move'">
                        <img src="{$Images}/folder_go.png" alt="Переместить" title="Переместить"/>
                      </xsl:when>
                      <xsl:when test="action = 'active'">
                        <xsl:choose>
                          <xsl:when test="$is_active = 1">
                            <img src="{$Images}/{img/on}" alt="Активный" title="Активный"/>
                          </xsl:when>
                          <xsl:otherwise>
                            <img src="{$Images}/{img/off}" alt="Не активный" title="Не активный" />
                          </xsl:otherwise>
                        </xsl:choose>
                      </xsl:when>
                      <xsl:when test="action = 'edit'">
                        <img src="{$Images}/folder_edit.png"  alt="Редактировать" title="Редактировать"/>
                      </xsl:when>
                      <xsl:otherwise>
                        <img src="{$Images}/{img}" />
                      </xsl:otherwise>
                    </xsl:choose>
                  </A>
                </div>
              </td>
            </xsl:for-each>
            -->
            </tr>
          </xsl:for-each>
        </tbody>
      </table>
    </form>
  </xsl:template>

</xsl:stylesheet>